<?php
namespace app\index\controller;

use app\common\ext\IDb;
use app\common\ext\IRequest;
use think\Controller;

class Wap extends Controller {

    /**
     * @功能：取得协议网页
     * @开发者：cxl
     */
    public function protocol(){
        //接收参数
        $protocol_code = IRequest::get("code");

        //读取缓存信息
//        $protocol_info = Cache::get('home_protocol_info_'.$protocol_code);
//        if(empty($protocol_info['protocol_id'])) {
            //取得协议内容
            $protocol_where['protocol_code'] = $protocol_code;
            $protocol_info = IDb::getInstance("com_protocol")
                ->setDbFiled("protocol_id,protocol_title,protocol_content")
                ->setDbWhere($protocol_where)
                ->row();

            //判断协议是否存在
            if (empty($protocol_info['protocol_id'])) {
                error("取得协议内容失败！");
            }

//            //保存缓存数据
//            Cache::set('home_protocol_info_'.$protocol_code,$protocol_info,3600 * 24);
//        }

        $show_button = false; //显示同意协议按钮
        if($protocol_code == 'LoanProtocol'){
            $show_button = true;
        }
        //页面赋值
        $this->assign("info",$protocol_info);
        $this->assign('show_button',$show_button);
        //渲染模板输出
        return view();
    }
}
